﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DVO;
using DAO;

public partial class DetailDocument : System.Web.UI.Page
{
    public int _Id = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Page.User.Identity.Name=="")
        {
            Response.Redirect("Login.aspx");
        }
        else
        {
            if (!String.IsNullOrEmpty(Request.QueryString["Id"]))
            {
                _Id = Convert.ToInt32(Request.QueryString["Id"].ToString());
            }
            if (IsPostBack == false)
            {
                if (_Id > 0)
                {
                    LoadData(_Id);
                }
            }
        }
        
    }

    #region "LoadData"
    private void LoadData(int WorkId)
    {
        BLL_Document ObjBLL = new BLL_Document();
        List<ins_Document_SelectByWorkIdResult> Objlist = new List<ins_Document_SelectByWorkIdResult>();
        Objlist = ObjBLL.Document_SelectByWorkId(WorkId).ToList();
        grid.DataSource = Objlist;
        grid.DataBind();
    }

    #endregion

    public string GetDocuMentName(string linkdocument)
    {
        string DocumentName = "";
        DocumentName = linkdocument.Substring(linkdocument.LastIndexOf("/") + 1, linkdocument.Length - linkdocument.LastIndexOf("/") - 1).ToString();
        return DocumentName;
    }

    public string GetStatus(string Status)
    {
        if (Status == "0")
            return "Chờ kiểm duyệt";
        else if (Status == "1")
            return "Đã duyệt";
        else if (Status == "2")
            return "Chờ phê duyệt";
        else if (Status == "3")
            return "Chỉnh sửa";
        return "";
    }
    protected void grid_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grid.PageIndex = e.NewPageIndex;
        LoadData(_Id);
    }
}